#include<cstdio>//uncle-lu
#include<algorithm>
template<class T>void read(T &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch<'0'||ch>'9') { f|=(ch=='-'); ch=getchar(); }
	while(ch<='9'&&ch>='0') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
	x = f ? -x : x;
	return ;
}

int n, m;
int map[51][51];
int F[51][51][51][51];

int main()
{
	read(n);read(m);
	for (int i = 1; i <= n; i++) 
		for (int j = 1; j <= m; j++) 
			read(map[i][j]);

	for (int i = 1; i <= n; i++) 
		for (int j = 1; j <= m; j++) 
			for (int k = 1; k <= n; k++) 
				for (int l = j+1; l <= m; l++) 
					F[i][j][k][l] = std::max(F[i-1][j][k-1][l], std::max(F[i-1][j][k][l-1], std::max(F[i][j-1][k-1][l], F[i][j-1][k][l-1] ) ) ) + map[i][j] + map[k][l];

	printf("%d", F[n][m-1][n-1][m]);

	return 0;
}
